#include "guocheng.h"

guocheng::guocheng(QObject *parent) : QObject(parent)
{
    m_wai = new wai;
    m_k = new kaichang;
    m_w1 = new Widget;
    m_wd = new windi;

    QObject::connect(m_wai,SIGNAL(showfh()),this,SLOT(recfh()));

    recfh();
}

void guocheng::recfh()
{
    m_k->startMovi();
    m_k->show();
    srand(time(NULL));
    int i=rand() % 3 + 1;
    if(i==1){
        QObject::disconnect(m_k,SIGNAL(showsj()),m_wai,SLOT(recvkaichang()));
        QObject::disconnect(m_wai,SIGNAL(showkaichang()),m_k,SLOT(recvsj()));
        QObject::connect(m_k,SIGNAL(showsj()),m_w1,SLOT(recvkaichang()));
        QObject::connect(m_w1,SIGNAL(showkaichang()),m_k,SLOT(recvsj()));

    }
    else if(i==2){
        QObject::disconnect(m_k,SIGNAL(showsj()),m_wai,SLOT(recvkaichang()));
        QObject::disconnect(m_wai,SIGNAL(showkaichang()),m_k,SLOT(recvsj()));
        QObject::connect(m_k,SIGNAL(showsj()),m_wd,SLOT(recvkaichang()));
        QObject::connect(m_wd,SIGNAL(showkaichang()),m_k,SLOT(recvsj()));

    }
    else {

        QObject::disconnect(m_k,SIGNAL(showsj()),m_wai,SLOT(recvkaichang()));
        QObject::disconnect(m_wai,SIGNAL(showkaichang()),m_k,SLOT(recvsj()));
        QObject::connect(m_k,SIGNAL(showsj()),m_wai,SLOT(recvkaichang()));
        QObject::connect(m_wai,SIGNAL(showkaichang()),m_k,SLOT(recvsj()));

    }

}
